/*------------------------------------------------------
                hou_elearningGEN beta v1.0
Author: xtrung.net@gmail.com
Write On: 04/27/2008
Create On:4/13/2012 11:22:57 AM
------------------------------------------------------*/
using hou_elearning.DataAccess.Base;
using hou_elearning.Entity;
using System;
using System.Data;
using System.Data.SqlClient;
using System.Configuration;
using System.Collections.Generic;
using System.Collections;
using System.Web;

namespace hou_elearning.DataAccess
{    
    public class Quyen_Chucnang_TacvuDAL : SqlProvider<Quyen_Chucnang_TacvuEntity>
    {
        static Quyen_Chucnang_TacvuDAL()
        {
            InitReader();
        }
        protected static void InitReader()
        {
            getFromReader=delegate(SqlDataReader dr)
            {
                Quyen_Chucnang_TacvuEntity entity = new Quyen_Chucnang_TacvuEntity();
				entity.FK_iChucnang_TacvuID = Int64.Parse("0"+dr["FK_iChucnang_TacvuID"].ToString());
				entity.FK_iQuyenID = Int16.Parse("0"+dr["FK_iQuyenID"].ToString());
                return entity;
            };
        }
        public static Quyen_Chucnang_TacvuEntity GetOne(Int64 FK_iChucnang_TacvuID)
        {
            string cmdName = "spQuyen_Chucnang_Tacvu_GetByPK";
            SqlParameter p = new SqlParameter("@FK_iChucnang_TacvuID", FK_iChucnang_TacvuID);
            Quyen_Chucnang_TacvuEntity entity = GetOne(cmdName, p);
            return entity;
        }
        public static List<Quyen_Chucnang_TacvuEntity> GetAll()
        {
            string cmdName = "spQuyen_Chucnang_Tacvu_Get";
            return GetList(cmdName);
        }
        
        public static int Add(Quyen_Chucnang_TacvuEntity entity)
        {
            string cmdName = "spQuyen_Chucnang_Tacvu_Insert";
            return Run(cmdName,true,initParams(entity));

        }
        public static bool Edit(Quyen_Chucnang_TacvuEntity entity)
        {
            string cmdName = "spQuyen_Chucnang_Tacvu_Update";
            return Run(cmdName,false,initParams(entity))>0;
        }
        public static bool Remove(Int64 FK_iChucnang_TacvuID)
        {
            string cmdName = "spQuyen_Chucnang_Tacvu_Delete";
            SqlParameter p = new SqlParameter("@FK_iChucnang_TacvuID", FK_iChucnang_TacvuID);
            return Run(cmdName,false,p)>0;
        }
        #region private
        private static SqlParameter[] initParams(Quyen_Chucnang_TacvuEntity entity)
        {
            SqlParameter[] p = new SqlParameter[2];
			p[0] = new SqlParameter("@FK_iChucnang_TacvuID", entity.FK_iChucnang_TacvuID);
			p[1] = new SqlParameter("@FK_iQuyenID", entity.FK_iQuyenID);
            return p;
        }
        #endregion
       
    }
}